package com.beiming.kotlindemo.sealed

import java.lang.Exception

/**
 * Created by lingchen on 2020/6/30. 23:23
 * mail:lingchen52@foxmail.com
 */
//密封类
sealed class Result
class Success(val msg: String) : Result()
class Failure(val error: Exception) : Result()
class Unknown(val info: String) : Result()

fun getResultMsg(result: Result) = when (result) {
    is Success -> result.msg
    is Failure -> result.error.message
    is Unknown -> result.info
}